package com.sakuraio.nextj.core.context;

import com.sakuraio.nextj.core.holder.SpringContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @author nekoimi 2023/9/25 16:10
 */
@Slf4j
public class SpringContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    @Override
    public void initialize(ConfigurableApplicationContext ctx) {
        SpringContextHolder.setInstance(ctx);

        Boolean debug = ctx.getEnvironment().getProperty("debug", Boolean.class);
        log.info("DEBUG模式：{}", debug);
        SpringContextHolder.setDebug(debug);
    }
}
